package com.ly.heart.service.impl;

import java.util.List;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

import com.ly.common.utils.DateUtils;
import com.ly.common.utils.SecurityUtils;
import com.ly.common.utils.erp.SnowflakeIdWorker;
import com.ly.heart.mapper.GiftRecordMapper;
import com.ly.heart.service.IGiftRecordService;
import org.springframework.stereotype.Service;
import com.ly.heart.domain.GiftRecordEntity;

import javax.annotation.Resource;

/**
 * 礼品申请记录Service业务层处理
 *
 * @author cxl
 * @date 2024-06-13
 */
@Service
public class GiftRecordServiceImpl extends ServiceImpl<GiftRecordMapper,GiftRecordEntity> implements IGiftRecordService {

    @Resource
    private GiftRecordMapper giftRecordMapper;

    /**
     * 查询礼品申请记录
     *
     * @param id 礼品申请记录ID
     * @return 礼品申请记录
     */
    @Override
    public GiftRecordEntity selectGiftRecordEntityById(String id)
    {
        return giftRecordMapper.selectGiftRecordEntityById(id);
    }

    /**
     * 查询礼品申请记录列表
     *
     * @param giftRecordEntity 礼品申请记录
     * @return 礼品申请记录
     */
    @Override
    public List<GiftRecordEntity> selectGiftRecordEntityList(GiftRecordEntity giftRecordEntity)
    {
        return giftRecordMapper.selectGiftRecordEntityList(giftRecordEntity);
    }

    /**
     * 新增礼品申请记录
     *
     * @param giftRecordEntity 礼品申请记录
     * @return 结果
     */
    @Override
    public int insertGiftRecordEntity(GiftRecordEntity giftRecordEntity)
    {
        giftRecordEntity.setId(SnowflakeIdWorker.getInstance().nextStringId());
        giftRecordEntity.setUserId(SecurityUtils.getLoginUser().getUser().getUserId());
        giftRecordEntity.setCreateTime(DateUtils.getNowDate());
        return giftRecordMapper.insertGiftRecordEntity(giftRecordEntity);
    }

    /**
     * 修改礼品申请记录
     *
     * @param giftRecordEntity 礼品申请记录
     * @return 结果
     */
    @Override
    public int updateGiftRecordEntity(GiftRecordEntity giftRecordEntity)
    {
        giftRecordEntity.setChangeTime(DateUtils.getNowDate());
        return giftRecordMapper.updateGiftRecordEntity(giftRecordEntity);
    }

    /**
     * 批量删除礼品申请记录
     *
     * @param ids 需要删除的礼品申请记录ID
     * @return 结果
     */
    @Override
    public int deleteGiftRecordEntityByIds(String[] ids)
    {
        return giftRecordMapper.deleteGiftRecordEntityByIds(ids);
    }

    /**
     * 删除礼品申请记录信息
     *
     * @param id 礼品申请记录ID
     * @return 结果
     */
    @Override
    public int deleteGiftRecordEntityById(String id)
    {
        return giftRecordMapper.deleteGiftRecordEntityById(id);
    }
}
